<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Model;

/**
 * 项目类别
 * Class Category
 * @package App\Model
 */
class Category extends Model
{
    /**
     * @var array
     */
    protected $fillable = ['name', 'sort'];

    public $timestamps = false;

    public function games()
    {
        return $this->hasMany(Game::class);
    }

    public static function getArr()
    {
        $data = self::orderBy('sort')->orderBy('id')->get();
        if (empty($data)) {
            return $data;
        }
        $result = [];
        foreach ($data as $v) {
            $result[$v['id']] = $v['name'];
        }
        return $result;
    }
}
